using UnityEngine;

public class BodyPartFire : MonoBehaviour
{
	public AudioSource audioSource;

	public AudioClip[] audioClip;

	public ParticleSystem ps;

	public BodyPart bodyPart;

	public float interval = 1f;

	public float damage = 1f;

	private float maxDamage = 5f;

	private void Start()
	{
		bodyPart = base.gameObject.GetComponentInParent<BodyPart>();
		if ((bool)bodyPart)
		{
			if ((bool)bodyPart.body.zombie && !bodyPart.body.zombie.isBurning)
			{
				bodyPart.body.zombie.isBurning = true;
				audioSource.clip = audioClip[Random.Range(0, audioClip.Length)];
				bodyPart.onFire.audioSource.Play();
			}
			InvokeRepeating("Hurt", interval, interval);
		}
	}

	public void Hurt()
	{
		damage = Mathf.Min(maxDamage, damage * 1.5f);
		bodyPart.body.health -= damage;
		if (bodyPart.body.health <= 0f)
		{
			Invoke("StopFire", 5f);
			bodyPart.body.Die();
		}
	}

	public void StopFire()
	{
		ps.Stop();
		audioSource.Stop();
	}
}
